<template>
    <div id="myNewsDetails">
        <header>
            <i @click="goBack()"></i>
            <div>消息</div>
        </header>
        <div class="border-8"></div>
        <div class="content">
                <h3>{{newsObj.name}}</h3>
                <p>
                    <time>{{newsObj.time}}</time>
                    <span></span>
                </p>
                <div>{{newsObj.content}}</div>

        </div>
    </div>
</template>
<script>
    export default {
        data() {
            return {
               xid: '', //消息id
               newsObj: {},
            }
        },
        components: {

        },
        methods: {
            goBack() {
                this.$router.back();
            },
            //获取消息详情
            getDetailsNews() {
                this.xid = this.$route.query.id;
                this.$api.get(this.$api.baseURLSchool,"select_cid/message/"+this.xid,{},r => {
                    // console.log(r);
                    if(r.data.ret == 1) {
                        this.newsObj = r.data.info;
                    }
                },err => {
                    console.log(err);
                })
            },
            //标记已读
            hasRead() {
                // read  是否读过  true 读过 false 未读
                const obj = {
                    id: this.xid,
                    read: true
                }
                console.log(obj);
                this.$api.post(this.$api.baseURLSchool,"updatedata/message/edit",obj,r => {
                    console.log(r);
                },err => {
                    console.log(err);
                })
            }
            
        },
        created() {
            this.getDetailsNews();
            this.hasRead();
        }
    }
</script>
<style lang="scss" scoped>

</style>
